package com.trickytriad.model
{
	import flash.events.EventDispatcher;
	
	import mx.collections.ArrayCollection;
	
	/**
	 * GameData class, stores game data pulled from the database.
	 **/
	[Bindable]
	public class GameData extends EventDispatcher
	{
		private var _game_id:int;
		private var _player1_id:Number;
		private var _player2_id:Number;
		private var _board:ArrayCollection;
		private var _hand1Array:ArrayCollection;
		private var _hand2Array:ArrayCollection;
		private var _turn:int;
		private var _gamestarted:int;
		private var _winner:int;				
		
		/**
		 *  Makes a GameData encapsulating class.
		 **/		
		public function GameData(in_game_id:int, in_player1_id:Number, in_player2_id:Number, 
				in_board:Array, in_hand1:Array, in_hand2:Array,
				in_turn:int, in_gamestarted:int, in_winner:int)
		{
			this._game_id = in_game_id;
			this._player1_id = in_player1_id;
			this._player2_id = in_player2_id;
			//this._playerDataArray[0] = PlayerManager.getPlayerById(in_player1_id);
			//this._playerDataArray[1] = PlayerManager.getPlayerById(in_player2_id);
			//this._board = in_board;
			//this._handArray[0] = in_hand1;
			//this._handArray[1] = in_hand2;
			// in_board should be an Array of TileData.			
			this._board = new ArrayCollection(in_board); 
			// in_hand1, in_hand2 should be arrays of TileData as well.
			this._hand1Array = new ArrayCollection(in_hand1);
			this._hand2Array = new ArrayCollection(in_hand2);		
			this._turn = in_turn;
			this._gamestarted = in_gamestarted;
			this._winner = in_winner;					
		}
		
		// Getters
		public function get gameId () : int { return _game_id; }
		
		// public function get playerData () : Array { return _playerDataArray; }
		
		// public function get boardData () : BoardData { return _board; }

		public function get player1_id () : Number { return _player1_id; }
		public function get player2_id () : Number { return _player2_id; }
		
		public function get board () : ArrayCollection { return _board; }
		
		public function get p1hand () : ArrayCollection { return _hand1Array; }
		public function get p2hand () : ArrayCollection { return _hand2Array; }
		
		public function get turn () : int { return _turn; }
	
		public function get gameStarted () : int { return _gamestarted; }

		public function get winner () : int { return _winner; }
		
	}
}